<%@ page contentType="text/html; charset=UTF-8"%>
<html>
	<HEAD>
		<title>角色菜单配置</title>
		<%@ include file="../jslib/jscsslib.jsp"%>
		<link rel="stylesheet" href="<%=request.getContextPath()%>/css/buttonforroleMenu.css" type="text/css" />
		
		<script language="javascript" src="../jslib/treeCheckBox.js"></script>
		<script type="text/javascript">
			function saveRoleMenu(){
				var result = {
			 		failure:function(resp){
			 			var resText = resp.responseText;
						var result = Ext.util.JSON.decode(resText);
						Ext.MessageBox.alert("错误",result.result);
			 		},
			 		success:function(resp){
			 			var resText = resp.responseText;
			 			var result = Ext.util.JSON.decode(resText);
			 			if(result.success){
				 			alert("权限配制成功");
				 			window.close();
			 			}else{
			 				Ext.MessageBox.alert("错误","权限配制失败，请与管理员联系！");
			 			}
			 		}
			 	}
			 	var menuId = document.getElementsByName("menu");
				var menuIds = "";
				for(var i=0;i<menuId.length;i++){
					if(menuId[i].checked == true && menuId[i].value!=0){
						menuIds += menuId[i].value+",";
					}
				}
				Ext.Ajax.request({
				   url: 'saveRoleMenu.action',
				   method:'post',
				   success: result.success,
				   failure: result.failure,
				   params: {menuIds: menuIds,roleId:document.getElementById("roleId").value}
				});	
			}
		</script>
	
	</head>
	<body>
		<form id="rolemenuForm">
		<input type="hidden" id="roleId" name="roleId" value="<%=request.getAttribute("roleId")%>" />
			<table  width="100%">
				<tr>
					<td>
						<div id="menutree" ></div>
						<DIV id="TreeView"></DIV>
					</td>
				</tr>
				<tr>
					<td height="10">
					</td>
				</tr>
				<tr>
					<td align="center">
						<input type="button" value=" 提 交 " onclick="saveRoleMenu()"  class="btn3_mouseout"
																			onMouseUp="this.className='btn3_mouseup'"
																			onmousedown="this.className='btn3_mousedown'"
																			onMouseOver="this.className='btn3_mouseover'"
																			onmouseout="this.className='btn3_mouseout'"/>
						<%--
						&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button"  value=" 关 闭 " onclick="javascript:window.close()"  class="btn3_mouseout"
																			onMouseUp="this.className='btn3_mouseup'"
																			onmousedown="this.className='btn3_mousedown'"
																			onMouseOver="this.className='btn3_mouseover'"
																			onmouseout="this.className='btn3_mouseout'"/>
						 --%>
						
					</td>
				</tr>
			</table>
		</form>
		<SCRIPT>
			var rowsPidIndex = new Object; 
			<%=(String)request.getAttribute("roleMenuContent")%>
			ctree = new  treeCheckBox( 'ctree'  , rows , rowsPidIndex ); 
			ctree.iconPath='../images/';
			ctree.useCheckBox=true;
			ctree.checkBoxName='menu';
			ctree.rootTitle="菜单列表";
			ctree.checkBoxChecked='<%=(String)request.getAttribute("checkedMenu")%>';
			ctree.toString(menutree);
		</SCRIPT>
	</body>
</html>